// DrvNumCom.h: interface for the CDrvNumCom class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_DRVNUMCOM_H__7CBBFD28_FAAD_11D7_9BE3_EFA09EEA3930__INCLUDED_)
#define AFX_DRVNUMCOM_H__7CBBFD28_FAAD_11D7_9BE3_EFA09EEA3930__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "SampleCtrl.h"


#define WM_RECVDATA     (WM_USER+123)
#define WM_RECVFRAME    (WM_USER+124)
#define WM_SENDDATA     (WM_USER+125)

typedef struct tagCOMMINFO
{
    BYTE   byPortNo;
    BYTE   byBaudRate;
	BYTE   byByteSize;
    BYTE   byParity;
    BYTE   byStopBits;
	BYTE   byFlowCtrl;
    BOOL   bFlowCtrl;
    BOOL   bXonXoff;
	BOOL   bConnected;
}COMMINFO, *LPCOMMINFO;

class CDrvNumCom
{
// Construction
public:
	CDrvNumCom();
	virtual ~CDrvNumCom();

// Attributes
public:
    COMMINFO   m_CommInfo;

// Operations
public:
	BOOL  InitComDevice();
	BOOL  SetupConnection();
    void  CloseComDevice();

public:
	void  DoStopSample();
	BOOL  DoSetMinute(BYTE byHour, BYTE byMinute);
	BOOL  DoStartSample(CSampleCtrl *pSampleCtrl);

private:
    int   InQueueLen();
	int   OutQueueLen();
    void  FlushComm(int nFlag);
    int   ReadCommBlock(char *RecvBuff, int nMaxLength);
    BOOL  WriteCommBlock(char *SendBuff, int nBytesToWrite);
    BOOL  SendChannelCmd(char *lpszCmd, char *lpszCorrRes, char *lpszErrRes, 
                         char *lpszTemp, DWORD dwTimeWait);

};

VOID CALLBACK ReadCallBack(int port);
VOID CALLBACK WriteCallBack(int port);
VOID CALLBACK StatusCallBack(int port);

#endif // !defined(AFX_DRVNUMCOM_H__7CBBFD28_FAAD_11D7_9BE3_EFA09EEA3930__INCLUDED_)
